#include <algorithm>
#include <cstdint>
#include <iostream>
#include <queue>
#include <vector>

using ll = int64_t;
struct Station {
    int id;
    int x, y;
};

using State = std::pair<ll, int>;

const ll INF = 1e18;

int main() {

    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n, m;
    std::cin >> n >> m;

    std::vector<Station> sta(m + 2);

    for (int i = 0; i < m; ++i) {
        sta[i].id = i;
        std::cin >> sta[i].x >> sta[i].y;
    }

    int startx, starty, endx, endy;
    std::cin >> startx >> starty >> endx >> endy;

    sta[m].id = m;
    sta[m].x = startx;
    sta[m].y = starty;

    sta[m + 1].id = m + 1;
    sta[m + 1].x = endx;
    sta[m + 1].y = endy;

    const int N = m + 2;
    const int prenode = 2 * N;
    std::vector<std::vector<std::pair<int, int>>> adj(prenode);

    std::vector<int> p(N);
    for (int i = 0; i < N; ++i)
        p[i] = i;

    std::sort(p.begin(), p.end(), [&](int a, int b) {
        if (sta[a].x != sta[b].x)
            return sta[a].x < sta[b].x;
        return sta[a].y < sta[b].y;
    });

    for (int i = 1; i < N; ++i) {
        int uidx = p[i - 1];
        int vidx = p[i];

        if (sta[uidx].x == sta[vidx].x) {
            ll weight = 2LL * (sta[vidx].y - sta[uidx].y);

            adj[uidx].push_back({vidx, (int)weight});
            adj[vidx].push_back({uidx, (int)weight});
        }
    }

    std::sort(p.begin(), p.end(), [&](int a, int b) {
        if (sta[a].y != sta[b].y)
            return sta[a].y < sta[b].y;
        return sta[a].x < sta[b].x;
    });

    for (int i = 1; i < N; ++i) {
        int uidx = p[i - 1];
        int vidx = p[i];

        if (sta[uidx].y == sta[vidx].y) {
            ll weight = 2LL * (sta[vidx].x - sta[uidx].x);

            adj[uidx + N].push_back({vidx + N, (int)weight});
            adj[vidx + N].push_back({uidx + N, (int)weight});
        }
    }

    if (startx == endx) {
        adj[m].push_back({m + 1, (int)(2LL * std::abs(starty - endy))});
        adj[m + 1].push_back({m, (int)(2LL * std::abs(starty - endy))});
    }
    if (starty == endy) {
        adj[m + N].push_back({m + 1 + N, (int)(2LL * std::abs(startx - endx))});
        adj[m + 1 + N].push_back({m, (int)(2LL * std::abs(startx - endx))});
    }

    for (int i = 0; i < m; ++i) {
        adj[i].push_back({i + N, 1});
        adj[i + N].push_back({i, 1});
    }

    std::vector<ll> dist(prenode, INF);
    std::priority_queue<State, std::vector<State>, std::greater<State>> pq;

    int startid = m;
    int endid = m + 1;

    dist[startid] = 0;
    pq.push({0, startid});
    dist[startid + N] = 0;
    pq.push({0, startid + N});

    while (!pq.empty()) {
        auto [d, u] = pq.top();
        pq.pop();

        if (d > dist[u]) {
            continue;
        }

        for (auto &edge : adj[u]) {
            int v = edge.first;
            int weight = edge.second;
            if (dist[u] + weight < dist[v]) {
                dist[v] = dist[u] + weight;
                pq.push({dist[v], v});
            }
        }
    }

    ll result = std::min(dist[endid], dist[endid + N]);

    if (result == INF) {
        std::cout << -1 << "\n";
    } else {
        std::cout << result << "\n";
    }
}